Frontend Forever App
We have a mobile app for you to download and use. And you can unlock many features in the app.
Get it now
Intall Later
Run
HTML
CSS
Javascript
Output
body { background-color: #030102; margin: 0; padding: 0; overflow: hidden; } .space { background: rgba(128, 0, 128, 0.1) center/200px 200px round; width: 100vw; height: 100vh; } .earth-container { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 200px; height: 200px; border-radius: 50%; z-index: 100; } .earth-pattern { width: 100%; height: 100%; position: relative; } .range-container { z-index: 100; position: absolute !important; left: 51%; top: 50%; transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); -moz-transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%); } #circle { width: 500px; height: 500px; border: 2px dashed #666; border-radius: 100%; float: left; margin-right: 40px; } #slider { position: relative; height: 30px; width: 30px; left: 235px; top: -15px; border-radius: 100%; cursor: pointer; background: #d6d6d6; } .range { float: left; width: 30px; } .stars-container { position: absolute; width: 100vw; height: 100vh; top: 0; z-index: -999; } .star { position: absolute; color: #ff6813; user-select: none; transition: opacity 0.5s ease-in-out; animation: pulse 1s infinite; } @keyframes pulse { 0% { transform: scale(1); filter: brightness(100%); } 50% { transform: scale(1.1); filter: brightness(130%); } 100% { transform: scale(1); filter: brightness(100%); } } .star.fade-in { opacity: 1; } .star.fade-out { opacity: 0; }
function fadeIn(element, duration) { element.style.opacity = 0; element.style.display = 'block'; let opacity = 0; const interval = 50; const gap = interval / duration; const fading = setInterval(() => { opacity += gap; element.style.opacity = opacity; if (opacity >= 1) { clearInterval(fading); } }, interval); } function fadeOut(element, duration) { let opacity = 1; const interval = 50; const gap = interval / duration; const fading = setInterval(() => { opacity -= gap; element.style.opacity = opacity; if (opacity <= 0) { clearInterval(fading); element.style.display = 'none'; } }, interval); } function placeStars(container, numStars) { const colors = ['red', 'blue', 'green', 'yellow', 'orange', 'purple', 'pink']; const minFontSize = 8; const maxFontSize = 10; const minStars = 40; const stars = container.querySelectorAll('.star'); for (let x = 1; x !== numStars; x++) { let randomAction = Math.random() < 0.5 ? 'add' : 'remove'; if (randomAction == 'add') { const star = document.createElement('div'); star.classList.add('star'); star.innerText = '+'; const randomTop = Math.random() * 100; const randomLeft = Math.random() * 100; star.style.top = `${randomTop}%`; star.style.left = `${randomLeft}%`; const randomColorIndex = Math.floor(Math.random() * colors.length); const randomColor = colors[randomColorIndex]; const randomFontSize = minFontSize + Math.random() * (maxFontSize - minFontSize); star.style.fontSize = `${randomFontSize}px`; container.appendChild(star); fadeIn(star, 1000); star.style.color = randomColor; } else { if (stars.length >= minStars) { const starsToRemove = Array.from(stars).slice(1); starsToRemove.forEach(star => { fadeOut(star, 1000); setTimeout(() => star.remove(), 1000); }); } } } } document.addEventListener('DOMContentLoaded', function() { var container = document.querySelector('.range-container'); var starsContainer = document.querySelector('.stars-container'); var slider = document.getElementById('slider'); var sliderW2 = slider.offsetWidth / 2; var sliderH2 = slider.offsetHeight / 2; var radius = 250; var deg = 0; var elP = document.getElementById('circle').getBoundingClientRect(); var elPos = { x: elP.left, y: elP.top }; var X = 0, Y = 0; var mdown = false; var numStars = 50; var debounceTimer = null; function debounce(func, delay) { clearTimeout(debounceTimer); debounceTimer = setTimeout(func, delay); } function handleMouseMove(e) { if (mdown) { var mPos = { x: e.clientX - elPos.x, y: e.clientY - elPos.y }; var atan = Math.atan2(mPos.x - radius, mPos.y - radius); deg = -atan / (Math.PI / 180) + 180; // final (0-360 positive) degrees from mouse position X = Math.round(radius * Math.sin(deg * Math.PI / 180)); Y = Math.round(radius * -Math.cos(deg * Math.PI / 180)); slider.style.left = X + radius - sliderW2 + 'px'; slider.style.top = Y + radius - sliderH2 + 'px'; slider.style.transform = 'rotate(' + deg + 'deg)'; slider.style.webkitTransform = 'rotate(' + deg + 'deg)'; slider.style.MozTransform = 'rotate(' + deg + 'deg)'; document.querySelector('input[name="angle"]').value = Math.ceil(deg); const newNumStars = Math.max(Math.ceil(Math.abs(deg) / 10) + 1, 5); placeStars(starsContainer, newNumStars); numStars = newNumStars; } } container.addEventListener('mousedown', function(e) { mdown = true; }); container.addEventListener('mouseup', function(e) { mdown = false; }); container.addEventListener('mousemove', function(e) { debounce(function() { handleMouseMove(e); }, 10); }); document.addEventListener('keydown', function(e) { if (e.key === 'ArrowLeft') { deg -= 5; } else if (e.key === 'ArrowRight') { deg += 5; } X = Math.round(radius * Math.sin(deg * Math.PI / 180)); Y = Math.round(radius * -Math.cos(deg * Math.PI / 180)); slider.style.left = X + radius - sliderW2 + 'px'; slider.style.top = Y + radius - sliderH2 + 'px'; slider.style.transform = 'rotate(' + deg + 'deg)'; slider.style.webkitTransform = 'rotate(' + deg + 'deg)'; slider.style.MozTransform = 'rotate(' + deg + 'deg)'; document.querySelector('input[name="angle"]').value = Math.ceil(deg); const newNumStars = Math.max(Math.ceil(Math.abs(deg) / 10) + 1, 5); placeStars(starsContainer, newNumStars); numStars = newNumStars; }); function handleTouchMove(e) { if (mdown) { var touch = e.touches[0]; var touchPos = { x: touch.clientX - elPos.x, y: touch.clientY - elPos.y }; var atan = Math.atan2(touchPos.x - radius, touchPos.y - radius); deg = -atan / (Math.PI / 180) + 180; // final (0-360 positive) degrees from touch position X = Math.round(radius * Math.sin(deg * Math.PI / 180)); Y = Math.round(radius * -Math.cos(deg * Math.PI / 180)); slider.style.left = X + radius - sliderW2 + 'px'; slider.style.top = Y + radius - sliderH2 + 'px'; slider.style.transform = 'rotate(' + deg + 'deg)'; slider.style.webkitTransform = 'rotate(' + deg + 'deg)'; slider.style.MozTransform = 'rotate(' + deg + 'deg)'; document.querySelector('input[name="angle"]').value = Math.ceil(deg); const newNumStars = Math.max(Math.ceil(Math.abs(deg) / 10) + 1, 5); placeStars(starsContainer, newNumStars); numStars = newNumStars; e.preventDefault(); // Prevent scrolling on touch devices } } container.addEventListener('touchstart', function(e) { mdown = true; }); container.addEventListener('touchend', function(e) { mdown = false; }); container.addEventListener('touchmove', function(e) { debounce(function() { handleTouchMove(e); }, 10); }); placeStars(starsContainer, numStars); });